package com.wzy.facetextview.Utils;

import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;

/**
 * add link string as part of textview click the link string, can start an activity
 */
public class TextLinkClickSpan extends ClickableSpan {
    private static final String TAG = "wang.TextLinkClickSpan";
    private ClickLinkListener mClickLinkListener;
    
    public TextLinkClickSpan(ClickLinkListener mClickLinkListener) {
        super();
        this.mClickLinkListener = mClickLinkListener;
    }
    
    @Override
    public void onClick(View widget) {
        
        if (mClickLinkListener != null) {
            mClickLinkListener.clickLinkCallBack(widget.getId());
        }
    }
    
    @Override
    public void updateDrawState(TextPaint ds) {
        
        ds.setColor(ds.linkColor);
        ds.setUnderlineText(true);
    }
    
    public interface ClickLinkListener {
        void clickLinkCallBack(int id);
    }
}
